package com.gedi.data.partition;

/**
 * @Author:RenPu
 * @Date: 2020/1/19 17:28
 * @Version: 1.0
 * @description:
 */


import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;



/**
 * 自定义Partition分区器
 */
public class CustmPartition extends Partitioner <Text, LongWritable> {


    @Override
    public int getPartition(Text text, LongWritable longWritable, int i) {
        if (text.toString().equals("CN-GD")) {
            return 0;
        } else if (text.toString().equals("CN-GX")) {
            return 1;
        } else if (text.toString().equals("CN-HK")) {
            return 2;
        } else if (text.toString().equals("JP-TY")) {
            return 3;
        } else {
            return 4;
        }

    }
}
